<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='./vue.js'></script>
</head>

<body>
    <div id='app'>
        app <button @click="add">点击count增加: {{count}} </button>
        <button @click="addNum">点击num增加: {{num}} </button>
    </div>

    <hr>

    <div id="bpp">
        bpp <button @click="add">点击count增加: {{count}} </button>
        <button @click="addNum">点击num增加: {{num}} </button>
    </div>
</body>
<script>

    /*
        mixin 是可以将一些公共的属性和方法放在一个混入中
        数据、函数、计算属性、侦听器，组件自身的优先级更高
        生命周期，混入的优先级更高

    */
    const myMixin = {
        data() {
            return {
                num: 88
            }
        },
        methods: {
            addNum() {
                this.num++
            }
        },
        mounted() {

        },
    }

    const app = {
        data() {
            return {
                count: 100,
                num: 99
            }
        },
        mixins: [myMixin],
        methods: {
            add() {
                this.count++
            }
        },
    }
    const vm = Vue.createApp(app).mount('#app')






    const bpp = {
        data() {
            return {
                count: 100
            }
        },
        mixins: [myMixin],
        methods: {
            add() {
                this.count++
            }
        },
    }
    const vm2 = Vue.createApp(bpp).mount('#bpp')
</script>

</html>